<?php
/**
 * Logger
 * @author Tomas Srna
 * @package bakalarka
 */
class Logger
{
	/**
	 * Logovanie
	 * @param string $message	Sprava
	 * @param string $type		Typ spravy (info|warning|error)
	 */
	public static function log($message, $type)
	{
		if($type != 'info' && $type != 'warning' && $type != 'error')
			throw new Exception("L::invalidType");
			
		$log = LogModel::create(array(
			'date' => new Expression('now()'),
			'user' => (Auth::instance()->isAuth() ? 
						Auth::instance()->getUser()->username :
						new Expression ('NULL')),
			'type' => $type,
			'message' => $message,
		));
		$log->save();
	}
}
